package svc

import (
	"paper-pro/app/chat/api/internal/config"
	"paper-pro/pkg/rpc/chat/client/chatdialogservice"
	"paper-pro/pkg/rpc/chat/client/chatmsgservice"
	"paper-pro/pkg/rpc/rag/ragclient"

	"github.com/zeromicro/go-queue/kq"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config config.Config

	RagRpc         ragclient.Rag
	ChatDialogRpc  chatdialogservice.ChatDialogService
	ChatMsgRpc     chatmsgservice.ChatMsgService
	KqPusherClient *kq.Pusher
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config: c,

		RagRpc:         ragclient.NewRag(zrpc.MustNewClient(c.RagRpcConf)),
		ChatDialogRpc:  chatdialogservice.NewChatDialogService(zrpc.MustNewClient(c.ChatRpcConf)),
		ChatMsgRpc:     chatmsgservice.NewChatMsgService(zrpc.MustNewClient(c.ChatRpcConf)),
		KqPusherClient: kq.NewPusher(c.KqPusherConf.Brokers, c.KqPusherConf.Topic),
	}
}
